import request from "../utils/request";

// 获取当前用户个人资料
export function getUserProfile() {
  return request({
    url: `/auth/profile`,
    method: "GET"
  });
}

// 关注用户
export function followUser(followerId, followedId) {
  return request({
    url: `/users/${followedId}/follow`,
    method: "POST",
    data: {
      follower_id: followerId
    }
  });
}

// 取消关注用户
export function unfollowUser(followerId, followedId) {
  return request({
    url: `/users/${followedId}/unfollow`,
    method: "DELETE",
    data: {
      follower_id: followerId
    }
  });
}

// 获取用户关注列表
export function getUserFollowing(userId, page = 1, perPage = 10) {
  return request({
    url: `/users/${userId}/following`,
    method: "GET",
    params: {
      page,
      per_page: perPage
    }
  });
}

// 获取用户粉丝列表
export function getUserFollowers(userId, page = 1, perPage = 10) {
  return request({
    url: `/users/${userId}/followers`,
    method: "GET",
    params: {
      page,
      per_page: perPage
    }
  });
}

// 通过用户名获取用户粉丝列表
export function getUserFollowersByUsername(username, page = 1, perPage = 10) {
  return request({
    url: `/users/username/${username}/followers`,
    method: "GET",
    params: {
      page,
      per_page: perPage
    }
  });
}

// 获取用户收藏量
export function getUserCollectionCount(userId) {
  return request({
    url: `/favorites/user/${userId}/count`,
    method: "GET"
  });
}

// 注销账号接口
export function deleteAccount () {
  return request({
    url: `/auth/delete-account`,
    method: 'DELETE'
  })
}

// 获取用户点赞数
export function getUserLikeCount(userId) {
  return request({
    url: `/likes/user/${userId}/count`,
    method: "GET"
  })
}

// 获取当前用户创建的所有食谱
export function getUserRecipes() {
  return request({
    url: `/recipes/user/recipes`,
    method: "GET"
  })
}

// 获取用户收藏的菜谱列表
export function getUserCollections(userId, page = 1, perPage = 10) {
  return request({
    url: `/favorites/user/${userId}`,
    method: "GET",
    params: {
      page,
      per_page: perPage
    }
  });
}

// 获取用户点赞的菜谱列表
export function getUserLikedRecipes(userId, page = 1, perPage = 10) {
  return request({
    url: `/likes/user/${userId}`,
    method: "GET",
    params: {
      page,
      per_page: perPage
    }
  });
}